<%@include file="/pub/import.jsp"%>
<%@include file="/pub/header.jsp"%>
<%    
    Project project = ProjectHandler.getProject(RequestUtil.getIntParameter(request,"id",0));
    
    List<User> userList = new ArrayList<User>();
    
    List<ScoreTree> treeList = ScoreTreeHandler.loadAll();
    
    String users = project.getScoreUser();
    if(!StringUtils.isEmpty(users)) {
      String[] userArr = users.split(",");
      for(String userId : userArr) {
        userList.add(UserHandler.getUser(Integer.parseInt(userId)));
      }
    }

    float totalScore = 0.0f;
    if(!StringUtils.isEmpty(project.getBuildUnit())) totalScore+=100;
    if(!StringUtils.isEmpty(project.getConstructUnit())) totalScore+=100;
    if(!StringUtils.isEmpty(project.getDesignUnit())) totalScore+=100;
    if(!StringUtils.isEmpty(project.getSupervisorUnit())) totalScore+=100;
    
    float currentScore = 0.0f;
    Map<Integer, List<ProjectItems>> tmpItem = (Map<Integer,List<ProjectItems>>) request.getSession().getAttribute("tmp_projectitem");
    if(tmpItem!=null) {
	    for(Integer key: tmpItem.keySet()) {
	      List<ProjectItems> list = tmpItem.get(key);
	      for(int i=0; i<list.size(); i++) {
	        System.out.println("item=" + list.get(i).getScore());
	        currentScore += list.get(i).getScore();
	      }
	    }
    }
    context.put("totalScore", totalScore);
    context.put("currentScore", currentScore);
    context.put("treeList", treeList);
    context.put("userList", userList); 
    context.put("project",project);
    context.put("DateUtil", new DateUtil());
    out.println(TemplateUtil.getOutput(context,"/view/project/newProjectView.html"));
%>
<%@include file="/pub/footer.jsp"%>